#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 100
typedef struct{
	int data[MAXSIZE];
	int front;
	int rear;
}queue;

void initqueue(queue *q)
{
	q->front=0;
	q->rear=0;
}

int isempty(queue *q)
{
	return q->front==q->rear;
}

int isfull(queue *q)
{
	return (q->rear+1)%MAXSIZE==q->front; 
}

void inqueue(queue *q,int v)
{
	if(isfull(q))
	{
		return ;
	}
	q->data[q->rear]=v;
	q->rear=(q->rear+1)%MAXSIZE;
}

int outqueue(queue *q)
{
	if(isempty(q))
	{
		return -1;
	}
	int v=q->data[q->front];
	q->front=(q->front+1)%MAXSIZE;
	return v;
}

void printqueue(int num)
{
	queue q;
	initqueue(&q);
	if(num==0)
	{
		printf("0");
		return ;
	}
	while(num!=0)
	{
		int r=num%8;
		inqueue(&q,r);
		num/=8;
	}
	
	while(!isempty(&q))
	{
		int m=outqueue(&q);
		printf("%d",m);
	}
}


int main()
{
	int n;
	scanf("%d",&n);
	int count=0;
	int b=n;
	if(n==0)
	{
		count=1;
	}
	else
	{
		while(n>0)
		{
			n=n/8;
			count++;
		}
	}
	printf("%d ",count);
	printqueue(b);
	printf("\n");
	return 0;
}
